<%@ page import="mdr.demo.utils.Constants" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
                <!-- Streettype/crud.gsp -->
        <title>${instancename} Details</title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">${instancename} List</g:link></span>
            <span class="menuButton"><g:link class="create" action="create">New ${instancename}</g:link></span>
        </div>
        <div class="body">
            <h1>${title}</h1>

            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${instance}">
            <div class="errors">
                <g:renderErrors bean="${instance}" as="list" />
            </div>
            </g:hasErrors>
                        <%-- the 'formactions' closure is called in 'InstanceController' --%>
            <g:form action="formactions" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                            <tr class="prop">
                                <td valign="top" class="name">
                                                                        <g:if test="${edit}">
                                                                                <label for="name">name</label>
                                                                        </g:if>
                                                                        <g:else>
                                                                                name
                                                                        </g:else>
                                </td>
                                <td valign="top" class="value ${hasErrors('bean': instance, field: 'name', 'errors')}">
                                                                        <g:if test="${edit}">
                                                                                <input type="text" maxlength="50" id="name" name="name" value="${fieldValue('bean': instance, 'field': 'name')}"/>
                                                                        </g:if>
                                                                        <g:else>
                                                                                ${instance?.name}
                                                                        </g:else>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                                <%-- Used in InstanceController/formactions --%>
                <input type="hidden" name="id" value="${instance?.id}" />
                <input type="hidden" name="mode" value="${mode}" />
                <div class="buttons">
                                        <g:if test="${edit}">
                                                <span class='button'><input class='save'  type='submit' name='operation' value='save'/></span>
                                        </g:if>
                                        <g:else>
                                                <span class='button'><input class='edit'  type='submit' name='operation' value='edit'/></span>
                                        </g:else>
                                        <g:if test="${mode != Constants.CREATE}">       <%-- Show the 'delete button only in 'show' or 'edit'. Not when creating a new instance --%>
                                                <span class='button'><input class='delete'  type='submit' name='operation' value='delete' onclick="return confirm('Delete, are you sure?');"/></span>
                                        </g:if>
                                                <span class='button'><input class='cancel' type='submit' name='operation' value='cancel'/></span>
                </div>
                        </g:form>
        </div>
    </body>
</html>